<template>
  <el-image-viewer
    v-if="isPreview"
    :visible="isPreview"
    @close="closeViewer"
    :url-list="srcList"
  />
</template>
<script setup>
const props = defineProps({
  isPreview: { type: Boolean, default: false },
  previewSrc: { type: [Array, String], default: () => [] },
});
const emit = defineEmits(["update:isPreview"]);
const { isPreview, previewSrc } = toRefs(props);
const srcList = computed(() => {
  return Array.isArray(previewSrc.value) ? previewSrc.value : [previewSrc.value];
});
const closeViewer = () => {
  emit("update:isPreview", false);
};
</script>
